package com.probox.modules.controller.order;

import com.probox.common.core.web.controller.BaseController;
import com.probox.order.api.domain.WxPaymentAmount;
import com.probox.order.api.domain.WxPaymentPayer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order/payment")
public class PaymentTestController extends BaseController {


    private WxPaymentAmount amount = new WxPaymentAmount(1L);
    //oSDoU5UGdFtD6tbavkE4HKmiKbDY

    private WxPaymentPayer payer = new WxPaymentPayer("oSDoU5QwW4lSIsGZTZ5LOiYMqU7s");




    @GetMapping("/wxPay")
    public Object wxPay() throws Exception {
        /*
       String out_trade_no = "test_"+System.currentTimeMillis();
        //支付的请求参数信息(此参数与微信支付文档一致，文档地址：https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_1.shtml)
        WxPayRequestBo wxPayRequestBo = new WxPayRequestBo()
                .setSp_appid(WechatV3Payment.sp_appid)
                .setSp_mchid(WechatV3Payment.sp_mchid)
                .setSub_appid(WechatV3Payment.sub_appid)
                .setSub_mchid(WechatV3Payment.sub_mchid)
                .setDescription("商品测试")
                .setOut_trade_no(out_trade_no)
                .setNotify_url(WechatV3Payment.notify_url)
                .setAmount(amount)
                .setPayer(payer);
        String wxPayRequestJsonStr = JSONUtil.toJsonStr(wxPayRequestBo);
        //第一步获取prepay_id
        String prepayId = WechatV3Payment.V3PayPartnerTransactionsJsapi(wxPayRequestJsonStr, PlatSourceEnum.applet.getKey());

        //第二步获取调起支付的参数
        JSONObject object = WechatV3Payment.WxTuneUp(prepayId, WechatV3Payment.sub_appid);
        return object;
         */
        return null;
    }
}
